package com.ruoyi.buss.qmcy.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.qmcy.domain.QmcyCustDgds;
import com.ruoyi.buss.qmcy.service.IQmcyCustDgdsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 对公对私帐户Controller
 * 
 * @author sxy
 * @date 2021-07-16
 */
@RestController
@RequestMapping("/dgds")
public class QmcyCustDgdsController extends BaseController
{
    @Autowired
    private IQmcyCustDgdsService qmcyCustDgdsService;

    /**
     * 查询对公对私帐户列表
     */
    @PreAuthorize(hasPermi = "buss:dgds:list")
    @GetMapping("/list")
    public TableDataInfo list(QmcyCustDgds qmcyCustDgds)
    {
        startPage();
        List<QmcyCustDgds> list = qmcyCustDgdsService.selectQmcyCustDgdsList(qmcyCustDgds);
        return getDataTable(list);
    }

    /**
     * 导出对公对私帐户列表
     */
    @PreAuthorize(hasPermi = "buss:dgds:export")
    @Log(title = "对公对私帐户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QmcyCustDgds qmcyCustDgds) throws IOException
    {
        List<QmcyCustDgds> list = qmcyCustDgdsService.selectQmcyCustDgdsList(qmcyCustDgds);
        ExcelUtil<QmcyCustDgds> util = new ExcelUtil<QmcyCustDgds>(QmcyCustDgds.class);
        util.exportExcel(response, list, "对公对私帐户数据");
    }

    /**
     * 获取对公对私帐户详细信息
     */
    @PreAuthorize(hasPermi = "buss:dgds:query")
    @GetMapping(value = "/{zh}")
    public AjaxResult getInfo(@PathVariable("zh") String zh)
    {
        return AjaxResult.success(qmcyCustDgdsService.selectQmcyCustDgdsById(zh));
    }

    /**
     * 新增对公对私帐户
     */
    @PreAuthorize(hasPermi = "buss:dgds:add")
    @Log(title = "对公对私帐户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QmcyCustDgds qmcyCustDgds)
    {
        return toAjax(qmcyCustDgdsService.insertQmcyCustDgds(qmcyCustDgds));
    }

    /**
     * 修改对公对私帐户
     */
    @PreAuthorize(hasPermi = "buss:dgds:edit")
    @Log(title = "对公对私帐户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QmcyCustDgds qmcyCustDgds)
    {
        return toAjax(qmcyCustDgdsService.updateQmcyCustDgds(qmcyCustDgds));
    }

    /**
     * 删除对公对私帐户
     */
    @PreAuthorize(hasPermi = "buss:dgds:remove")
    @Log(title = "对公对私帐户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{zhs}")
    public AjaxResult remove(@PathVariable String[] zhs)
    {
        return toAjax(qmcyCustDgdsService.deleteQmcyCustDgdsByIds(zhs));
    }
}
